# Contributor: Sören Tempel <soeren+alpinelinux@soeren-tempel.net>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=harfbuzz
pkgver=4.4.1
pkgrel=0
pkgdesc="Text shaping library"
url="https://freedesktop.org/wiki/Software/HarfBuzz"
arch="all"
license="MIT"
makedepends="freetype-dev glib-dev gobject-introspection-dev cairo-dev icu-dev
	graphite2-dev meson gtk-doc"
checkdepends="python3"
subpackages="$pkgname-static $pkgname-dev $pkgname-icu $pkgname-utils $pkgname-doc"
source="harfbuzz-$pkgver.tar.gz::https://github.com/harfbuzz/harfbuzz/archive/$pkgver.tar.gz"

build() {
	abuild-meson \
		--default-library=both \
		-Dglib=enabled \
		-Dgobject=enabled \
		-Dgraphite=enabled \
		-Dicu=enabled \
		-Dfreetype=enabled \
		-Dcairo=enabled \
		-Ddocs=enabled \
		. output
	meson compile ${JOBS:+-j ${JOBS}} -C output
}

check() {
	meson test --no-rebuild -v -C output
}

package() {
	DESTDIR="$pkgdir" meson install --no-rebuild -C output
}

static() {
	pkgdesc="$pkgdesc (static libraries)"

	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/*.a "$subpkgdir"/usr/lib/
}

icu() {
	pkgdesc="Harfbuzz ICU support library"
	replaces="harfbuzz"
	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/lib*icu.so.* "$subpkgdir"/usr/lib/
}

utils() {
	pkgdesc="$pkgdesc (utilities)"
	mkdir -p "$subpkgdir"/usr
	mv "$pkgdir"/usr/bin "$subpkgdir"/usr/
}

sha512sums="
bbc415d7b74408b1e8d34bfbc19a3cab002471fdd56d71b469c3129f0eae5532d5c7aaae7bb5cc3942fea6008d2ed9e96a7b20b10f4f5e46db63cecfa5c0248e  harfbuzz-4.4.1.tar.gz
"
